2) Visual step up/down through the history list.
3) Terminal mode sanity checking and resetting.
4) Interactive command, file name and user name completion.
5) File/directory/user list in the middle of a typed command.
6) Spelling correction of command, file, and user names.
7) Lookup of command documentation in the middle of a typed command.
8) History saved between logouts.
9) Automatic logout after long periods of idle time.
10) Automatic execution of a single command prior to printing each prompt.
11) Automatic periodic command execution.
12) A new syntax for the prompt, and the ability to set the prompt for
"while" and "for" loops.
13) Time stamps in the history list.
14) An addition to the syntax of filenames to access entries in the
directory stack.
15) The ability to watch for logins and logouts by user or terminal
on the machine.
16) A scheduled event list, which specifies commands which are to be
executed at given times.
17) A new builtin that does a subset of
ls (1).
18) An addition to the file expression syntax for a character not
in a set of characters.
19) New automatically initialized environment variables HOST and
HOSTTYPE.
20) Commands for debugging terminal capabilities.
21) Searching for the visual history mechinism.
22) A new builtin for the which(1) command.
23) Restarting a stopped editor with two keystrokes.
24) Automatic execution of a command when the current working
directory is changed.
25) Automatic execution of commands on an idle host.
For a description of standard C-shell features, see the csh manual page.
EMACS functions set-mark-command ^@ beginning-of-line ^A backward-char ^B tty-sigintr ^C delete-char-or-list ^D end-of-line ^E forward-char ^F backward-delete-char ^H complete-word ^I newline ^J kill-line ^K clear-screen ^L newline ^M down-history ^N tty-flush-output ^O up-history ^P tty-start-output ^Q redisplay ^R tty-stop-output ^S transpose-chars ^T universal-argument ^U quoted-insert ^V kill-region ^W extended-key-prefix ^X yank ^Y tty-sigtsusp ^Z prefix-meta ^[ tty-sigquit ^\ tty-dsusp ^] digit 0 through 9 self-insert-command A through Z self-insert-command a through z self-insert-command SPACE ! # $ % & " ' ` * + , - . / \ self-insert-command : ; ( ) < > { } [ ] = ? @ ^ _ | ~ backward-delete-char ^? list-choices M-^D backward-delete-word M-^H complete-word M-^I clear-screen M-^L run-fg-editor M-^Z complete-word M-^[ spell-word M-$ digit-argument M-0 through M-9 which-command M-? backward-word M-B capitalize-word M-C delete-word M-D forward-word M-F run-help M-H downcase-word M-L history-search-forward M-N function-key-prefix M-O history-search-backward M-P spell-word M-S upcase-word M-U copy-region-as-kill M-W function-key-prefix M-[ backward-word M-b capitalize-word M-c delete-word M-d forward-word M-f run-help M-h downcase-word M-l history-search-forward M-n history-search-backward M-p spell-word M-s upcase-word M-u copy-region-as-kill M-w backward-delete-word M-^? EMACS Extended mode functions (^X) exchange-point-and-mark ^X VI Insert Mode functions tty-sigintr ^C list-or-eof ^D backward-delete-char ^H complete-word ^I newline ^J kill-line ^K clear-screen ^L newline ^M tty-flush-output ^O tty-start-output ^Q redisplay ^R tty-stop-output ^S backward-kill-line ^U quoted-insert ^V backward-delete-word ^W prefix-meta ^X tty-dsusp ^Y tty-sigtsusp ^Z vi-cmd-mode ^[ (escape key) tty-sigquit ^\ backward-delete-char ^? (delete key) self-insert-command 0 thru 9, A thru Z, a thru z self-insert-command SPACE ! # $ % & " ' ` * + , - . / \ self-insert-command : ; ( ) < > { } [ ] = ? @ ^ _ | ~ VI Command Mode functions beginning-of-line ^A tty-sigintr ^C list-choices ^D end-of-line ^E backward-delete-char ^H complete-word ^I newline ^J kill-line ^K clear-screen ^L newline ^M down-history ^N tty-flush-output ^O up-history ^P tty-start-output ^Q redisplay ^R tty-stop-output ^S backward-kill-line ^U backward-delete-word ^W prefix-meta ^[ tty-sigquit ^\ forward-char SPACE end-of-line $ vi-zero 0 digit-argument 1 through 9 which-command ? vi-add-at-eol A backward-word B vi-chg-to-eol C kill-line D vi-insert-at-bol I history-search-forward J history-search-backward K function-key-prefix O vi-replace-mode R vi-substitute-line S forward-word W backward-delete-char X function-key-prefix [ beginning-of-line ^ vi-add a backward-word b delete-word d backward-char h vi-insert i down-history j up-history k forward-char l vi-replace-char r vi-substitute-char s vi-beginning-of-next-word w delete-char x backward-delete-char ^? (delete key) run-help M-? function-key-prefix M-O function-key-prefix M-[ Alphabetical list of function names "backward-char" "backward-delete-char" "backward-delete-word" "backward-kill-line" "backward-word" "beginning-of-line" "capitalize-word" "clear-screen" "complete-word" "copy-region-as-kill" "delete-char" "delete-char-or-list" "delete-word" "digit" "digit-argument" "down-history" "downcase-word" "end-of-file" "end-of-line" "exchange-point-and-mark" "extended-key-prefix" "forward-char" "forward-word" "function-key-prefix" "gosmacs-transpose-chars" "history-search-backward" "history-search-forward" "insert-last-word" "keyboard-quit" "kill-line" "kill-region" "kill-whole-line" "list-choices" "list-or-eof" "newline" "prefix-meta" "quoted-insert" "redisplay" "run-fg-editor" "run-help" "self-insert-command" "set-mark-command" "spell-word" "transpose-chars" "tty-dsusp" "tty-flush-output" "tty-sigintr" "tty-sigquit" "tty-sigtsusp" "tty-start-output" "tty-stop-output" "universal-argument" "up-history" "upcase-word" "vi-beginning-of-next-word" "vi-cmd-mode" "vi-add" "vi-add-at-eol" "vi-insert" "vi-insert-at-bol" "vi-replace-char" "vi-replace-mode" "vi-substitute-char" "vi-substitute-line" "vi-zero" "which-command" "yank"
There is a new shell command, bind, that allows the user to redefine what any key does, or find out what any or all of the keys do.
If given two arguments bind binds the function (first argument) to the given key (second argument). The key may be: the direct character or a caret-<letter> combination, which is converted to control-<letter>; M-<letter> for an escaped character; or X-<string> for a function key. For the last of these, the function key prefix must be bound to the function "extended-key-prefix" and the string specified to the bind command must not include this prefix. By default (in both emacs and vi modes), "extended-key-prefix" is bound to M-[ and M-O (capital-oh) for the arrow keys and F1 through F20 function keys on ANSI terminals.
If given one argument bind takes the argument as the name for a key and tells what that key does.
If given no arguments bind tells what all of the keys do. If you give bind the single argument of 'defaults', it resets each key to its default value (see the above list).
> ls foo bar > echo mumble mumble >
then enters ^P, the shell will place "echo mumble" into the editing buffer, and will put the cursor at the end of the line. If another ^P is entered, then the editing line will change to "ls". More ^Ps will make the bell ring, since there are no more lines in the history. ^N works the same way, except it steps down (forward in time).
An easy way to re-do a command is to type ^P followed by Return. Also, pieces of previous commands can be assembled to make a new command. The commands that work on regions are especially useful for this.
^P and ^N actually only copy commands from out of the history into the edit buffer; thus the user may step back into the history and then edit things, but those changes do not affect what is actually in tcsh's history.
Example
Assume the current directory contained the files:
DSC.TXT bin cmd lib memos DSC.NEW chaos cmtest mail netnews bench class dev mbox new
The command:
would cause tcsh to complete the command with the file name chaos. If instead, the user had typed:
tcsh would have extended the name to DSC and rung the terminal bell, indicating partial completion. However, if fignore had previously been set to a list containing .NEW as one element, e.g. ( .o .NEW ), tcsh would have completed the `D' to DSC.TXT.
File name completion works equally well when other directories are addressed. Additionally, tcsh understands the C shell tilde (~) convention for home directories. Thus,
does what one might expect. This may also be used to expand login names only. Thus,
expands to
Command names may also be completed, for example,
will expand to "gnumacs" (assuming that there are no other commands that begin with "gnum").
Completion also works when the cursor is in the middle of the line, rather than just the end. All of the text after the cursor will be saved, the completion will work (possibly adding to the current name), and then the saved text will be restored in place, after the cursor.
you may wish to know what files or subdirectories exist (in ~speech/data/fritz), without, of course, aborting the command you are typing. Typing the character Control-D (^D), will list the names (files, in this case) available. The files are listed in multicolumn format, sorted column-wise. Directories are indicated with a trailing `/', executable files with a `*', symbolic links with a '@', sockets with a '=', and FIFOs (named pipes) with a '<'. Once printed, the command is re-echoed for you to complete.
Additionally, one may want to know which files match a prefix. If the user had typed:
all files and subdirectories whose prefix was ``fr'' would be printed. Notice that the example before was simply a degenerate case of this with a null trailing file name. (The null string is a prefix of all strings.) Notice also, that a trailing slash is required to pass to a new directory for both file name completion and listing.
The degenerate
will print a full list of login names on the current system.
The behavior of the completion can be changed by setting the shell variable recexact. This makes an exact command be expanded rather than just ringing the bell. For example, assume the current directory has two subdirectories called foo and food, then with recexact set the following could be done:
rather than beeping on the second TAB.
For covert operation, the variable nobeep, can be set, preventing the completion mechanism from actually beeping.
might expand to
Also,
would list all commands (along PATH) that begin with "new".
Note that Control-D has three different effects on tcsh. On an empty line (one that contains nothing, not even spaces), ^D sends an EOF to tcsh just as it does for normal programs. When the cursor is in the middle of a line of text, ^D deletes the character that the cursor is under. Finally, a ^D at the end of a line of text lists the available names at that point. To get a list of available names when the cursor is in the middle of a line (or on an empty line), a Meta-Control-D should be typed (Escape followed by Control-D).
Tcsh will check the path for spelling, correct the mistakes, and redraw the line as
leaving the cursor at the end of the line. This, like the other commands that affect names, works for command names and user names also.
tells csh to save the last 25 commands on the history list, and to save the last 20 of them between logins. The "savehist" variable may be set up to the size of history, although it is an error to have savehist larger than history.
then the program date will be run just before the shell prompts for each command. There are no limitations on what precmd can be set to do, although discretion should be used.
%d or %/ Current working directory. %~ cwd. If it starts with $HOME, that part is replaced by a ~. %c or %. Trailing component of cwd. %h, %! Current history event number. %M The full machine hostname %m The hostname up to the first "." %S (%s) Start (stop) standout mode. %t or %@ Current time of day, in 12-hour, am/pm format (but see the "ampm" shell variable below). %T Current time of day, in 24-hour format. %% A single %.
The sequences for standout are often used to indicate that this is an enabled (running as root) shell. An example:
> set prompt="%m [%h] %S[%@]%s [%/] you rang? " tut [37] [2:54pm] [/usr/accts/sys] you rang? _
In addition, there is a new variable, prompt2, which is used to prompt for the body of while and for loops (wherever normal csh prompts with a question mark). The default for prompt2 is "\? ": a (quoted) question mark followed by a space.
In the normal csh, saying "pushd +2" would rotate the entire stack around through 2 stack elements, placing the entry found there at the top of the stack. If, however, the new shell variable dextract is set, then issuing "pushd +n" will cause the nth directory stack element to be extracted from its current position, which will then be pushed onto the top of the stack. Example:
By default, the interval between checks of users on the system is 10 minutes; this can be changed by making the first element of watch a number of minutes which should be used instead, as in
There is also a new command, log, which is used to cause csh to inform the user of all users/terminals affected by watch whether they have been announced before or not. This is useful if a user has been on for some time and cannot remember if a particular person/terminal is online right now or not. Log will reset all indication of previous announcement and give the user the login list all over again, as well as printing the current value of watch.
The first time that watch is set at csh startup, all affected users and terminals will be printed as though those users/terminals had just logged on. This may appear to be a bug, but is generally considered a feature, since it allows the user to see who is on when he first logs in.
Printing the current time-event list is accomplished by giving the sched command with no arguments:
This mechanism is similar to, but not the same as, the at(1) command on some Unix systems. Its major disadvantage is that it does not necessarily run a command at exactly the specified time (but only if another command is already being run). Its major advantage is that commands which run directly from the csh, as sched commands are, have access to shell variables and other structures. This provides a mechanism for changing one's working environment based on the time of day.
Note that the second form includes .Xdefaults and .Xinit because 'X' (and all the lower case letters) are outside of the range of a single '.'.
Tcsh also initializes the environment variable HOSTTYPE to a symbolic name for the type of computer that it is running on. The current possible values are:
alliant an Alliant FX series att3b2 an AT&T 3b2 att3b5 an AT&T 3b5 att3b15 an AT&T 3b15 att3b20 an AT&T 3b15 ballance a Sequent Ballance (32000 based) butterflyR a BBN Computer Butterfly 1000 convex a Convex hp9000s300 an HP 9000, series 300 workstation hp9000s800 an HP 9000, series 800 workstation hp an HP, but not an hp9000s800 multimax an Encore Computer Corp. Multimax (32000 based) mac2 an Apple Computer Macintosh II pyramid a Pyramid Technology computer (of any flavor) rt an IBM PC/RT running Mach rtpc an IBM PC/RT running IBM's BSD port sun2 a Sun Microsystems series 2 workstation (68010 based) sun3 a Sun Microsystems series 3 workstation (68020 based) sun4 a Sun Microsystems series 4 workstation (SPARC based) sun386i a Sun Microsystems 386i workstation (386 based) sun a Sun workstation of none of the above types symmetry a Sequent Symmetry (386 based) vax a Digital Equipment Corp. Vax (of any flavor)
(The names of the machines are usually trade marks of the corresponding companies.) This is useful when sharing a single physical directory between several types of machines (running NFS, for instance). For example, if the following is in .login:
and the user has directories named "bin.machine" (where machine is a name from the above list), then the user can have the same programs compiled for different machines in the appropriate "bin.machine" directories and tcsh will run the binary for the correct machine.
Tcsh also initializes the shell variable uid to the value of the current real user ID. This is useful for telling what user the shell is running as.
and then types "echo<ESC>p", the shell will place "echo bar" in the editing buffer. If another M-p was entered, the editing buffer would change to "echo foo". This capability is compatable with the plain visual history; if the user were to then enter ^P the editing buffer would be changed to "ls".
then the shell will change the title of the running xterm to be the name of the host, a colon, and the full current working directory. Note that if a user defines cwdcmd to contain a cd, pushd, or popd, command, an infinite loop may result. In this case, it is the author's opinion that said user will get what he deserves.
Note that not all commands are totally location-independent, and that commands will take up idle hosts that other users might be able to use. Therefore, run commands remotely only when they are CPU-intensive. The file
This shell will restore your tty to a sane mode if it appears to return from some command in raw, cbreak, or noecho mode.
I am certain that there are bugs. Bugs (preferably with fixes) should be sent to Paul Placeway (paul@cis.ohio-state.edu)
Mike Ellis, Fairchild, 1983 Added command name recognition/completion.
Paul Placeway, Ohio State CIS dept., 1983 Added the command line editor.
Rayan Zachariassen, University of Toronto, 1984 Added the builtin which feature to the editor, and the code for ls-F. Also numerous bug fixes, modifications, and performance enhancements.
Chris Kingsley, Caltech. Wrote the fast storage allocator routines (nmalloc.c).
Karl Kleinpaste, CCI 1983-4 Added special aliases, directory stack extraction stuff, login/logout watch, and scheduled events. Also came up with the idea of the new prompt format.
Paul Placeway, Ohio State CIS dept., 1987 Re-wrote the editor, cleaned up other code, and added the prompt routines, added to the syntax for file name expressions, and sped up the shell some.
Chris Grevstad, TRW, 1987 Ported the 4.3 csh sources to tcsh.
Christos S. Zoulas, Cornell U. EE dept., 1987-89 ported tcsh to HPUX, and System V rel. 2 and 3 and wrote a SysV version of getwd.c
James J Dempsey, BBN, 1988, and Paul Placeway, OSU, 1988. Re-ported tcsh to A/UX
Michael Bloom Fixed some of the interupt handeling
Michael Fine, Digital Equipment Corp. added the extended key support
Daniel Long, NNSC, 1988 Added the wordchars variable
George Hartzell, MCD Biology, University of Colorado-Boulder, 1988 fixed the allways reseting to DEL bug.
Patrick Wolfe, KAI, 1988 Cleaned up VI mode and wrote the new editor discription (in section 1).
Jak Kirman, 1988 Fixed the SunOS 4 giant stack allocation bug.
Bruce Robertson, Tektronix, 1989 Fixed setting erase and kill (again).
Also, thanks to all the people on the net for putting up with, reporting bugs in, and suggesting new additions to the old tcsh editor.